package org.finir.fakturisanje.persistence.beans;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.finir.fakturisanje.persistence.Faktura;
import org.finir.fakturisanje.persistence.Preduzece;
import org.finir.fakturisanje.persistence.Skladiste;


@Entity
public class SkladisteBean implements Skladiste, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long id;
	private String naziv;
	private Integer idBroj;
	private String vrstaSkladista;
	private String oznaka;
	private List<Faktura> fakture;
	private Preduzece preduzece;

	@ManyToOne(targetEntity = PreduzeceBean.class)
	public Preduzece getPreduzece() {
		return preduzece;
	}

	public void setPreduzece(Preduzece preduzece) {
		this.preduzece = preduzece;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getFakture()
	 */
	@OneToMany(targetEntity = FakturaBean.class, cascade = CascadeType.ALL, mappedBy = "skladiste")
	public List<Faktura> getFakture() {
		return fakture;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setFakture(java.util.List)
	 */
	public void setFakture(List<Faktura> fakture) {
		this.fakture = fakture;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof SkladisteBean)) {
			return false;
		}
		SkladisteBean other = (SkladisteBean) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getId()
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getNaziv()
	 */
	public String getNaziv() {
		return naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setNaziv(java.lang.String)
	 */
	public void setNaziv(String naziv) {
		this.naziv = naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getIdBroj()
	 */
	public Integer getIdBroj() {
		return idBroj;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setIdBroj(java.lang.Integer)
	 */
	public void setIdBroj(Integer idBroj) {
		this.idBroj = idBroj;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getVrstaSkladista()
	 */
	public String getVrstaSkladista() {
		return vrstaSkladista;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setVrstaSkladista(java.lang.String)
	 */
	public void setVrstaSkladista(String vrstaSkladista) {
		this.vrstaSkladista = vrstaSkladista;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#getOznaka()
	 */
	public String getOznaka() {
		return oznaka;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.jk#setOznaka(java.lang.String)
	 */
	public void setOznaka(String oznaka) {
		this.oznaka = oznaka;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

}
